package com.tiger.life;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class StartActivity extends BaseActivity {
	private Bundle bundle;

	private int checkFlag;
	private ImageButton  exit;
	private ImageButton start;
	private LinearLayout start_bg;
	private ImageView start_desc_img;
	private TextView start_desc_txt;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		bundle = this.getIntent().getExtras();
		checkFlag = bundle.getInt(CommonUtil.checkFlag);

		this.setContentView(R.layout.start);
//		if (checkFlag == CommonUtil.checkFlagValue.cigar_Flag) {
//			setContentView(R.layout.cigar_start);
//		} else if (checkFlag == CommonUtil.checkFlagValue.baby_Flag) {
//			setContentView(R.layout.baby_start);
//		} else if (checkFlag == CommonUtil.checkFlagValue.weight_Flag) {
//			setContentView(R.layout.weight_start);
//		} else if (checkFlag == CommonUtil.checkFlagValue.calorie_Flag) {
//			setContentView(R.layout.calorie_start);
//		} else if (checkFlag == CommonUtil.checkFlagValue.chest_Flag) {
//			setContentView(R.layout.chest_start);
//		} else if (checkFlag == CommonUtil.checkFlagValue.xingzuo_Flag) {
//			setContentView(R.layout.xingzuo_start);
//		} else if (checkFlag == CommonUtil.checkFlagValue.eredar_Flag) {
//			setContentView(R.layout.eredar_start);
//		} else if (checkFlag == CommonUtil.checkFlagValue.rumor_Flag) {
//			setContentView(R.layout.rumor_start);
//		} else {
//			setContentView(R.layout.dog_start);
//		}

		initView();
		initAction();
	}

	public void initView() {
		start = (ImageButton) this.findViewById(R.id.start);
		exit = (ImageButton) this.findViewById(R.id.exit);
		start_bg=(LinearLayout)this.findViewById(R.id.start_bg);
		start_desc_img=(ImageView)this.findViewById(R.id.start_desc_img);
		start_desc_txt=(TextView)this.findViewById(R.id.start_desc_txt);
		if (checkFlag == CommonUtil.checkFlagValue.cigar_Flag) {
			start_bg.setBackgroundResource(R.drawable.bg_cigar);
			start_desc_img.setBackgroundResource(R.drawable.desc_cigar);
			start_desc_txt.setText(R.string.app_cigar_desc);
		} else if (checkFlag == CommonUtil.checkFlagValue.baby_Flag) {
			start_bg.setBackgroundResource(R.drawable.bg_baby);
			start_desc_img.setBackgroundResource(R.drawable.desc_baby);
			start_desc_txt.setText(R.string.app_baby_desc);
		} else if (checkFlag == CommonUtil.checkFlagValue.weight_Flag) {
			start_bg.setBackgroundResource(R.drawable.bg_weight);
			start_desc_img.setBackgroundResource(R.drawable.desc_weight);
			start_desc_txt.setText(R.string.app_weight_desc);
			start_desc_txt.setTextColor(this.getResources().getColor(R.color.clr_huise));
		} else if (checkFlag == CommonUtil.checkFlagValue.calorie_Flag) {
			start.setImageResource(R.drawable.start_jisuan);
			start_bg.setBackgroundResource(R.drawable.bg_calorie);
			start_desc_img.setBackgroundResource(R.drawable.desc_calorie);
			start_desc_txt.setText(R.string.app_calorie_desc);
			start_desc_txt.setTextColor(this.getResources().getColor(R.color.clr_black));
		} else if (checkFlag == CommonUtil.checkFlagValue.chest_Flag) {
			start.setImageResource(R.drawable.start_liaojie);
			start_bg.setBackgroundResource(R.drawable.bg_chest);
			start_desc_img.setBackgroundResource(R.drawable.desc_chest);
			start_desc_txt.setText(R.string.app_chest_desc);
		} else if (checkFlag == CommonUtil.checkFlagValue.xingzuo_Flag) {
			start_bg.setBackgroundResource(R.drawable.bg_xingzuo);
			start_desc_img.setBackgroundResource(R.drawable.desc_xingzuo);
			start_desc_txt.setText(R.string.app_xingzuo_desc);
			start_desc_txt.setTextColor(this.getResources().getColor(R.color.clr_white));
		} else if (checkFlag == CommonUtil.checkFlagValue.eredar_Flag) {
			start_bg.setBackgroundResource(R.drawable.bg_eredar);
			start_desc_img.setBackgroundResource(R.drawable.desc_eredar);
			start_desc_txt.setText(R.string.app_eredar_desc);
			start_desc_txt.setTextColor(this.getResources().getColor(R.color.clr_black));
		} else if (checkFlag == CommonUtil.checkFlagValue.rumor_Flag) {
			start_bg.setBackgroundResource(R.drawable.bg_rumor);
			start_desc_img.setBackgroundResource(R.drawable.desc_rumor);
			start_desc_txt.setText(R.string.app_rumor_desc);
		} else {
			start_bg.setBackgroundResource(R.drawable.bg_dog);
			start_desc_img.setBackgroundResource(R.drawable.desc_dog);
			start_desc_txt.setText(R.string.app_dog_desc);
		}
	}
	public void initAction() {
		
		start.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				Intent intent;
				if (checkFlag == CommonUtil.checkFlagValue.rumor_Flag) {
					intent = new Intent(StartActivity.this,CheckYaoActivity.class);
				}else if(checkFlag == CommonUtil.checkFlagValue.xingzuo_Flag){
					intent = new Intent(StartActivity.this,CheckXingzuoActivity.class);
				}else{
					intent = new Intent(StartActivity.this, CheckActivity.class);
				}
				intent.putExtras(bundle);
				// TODO Auto-generated method stub
				StartActivity.this.startActivity(intent);
			}

		});
	
		exit.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				StartActivity.this.startActivity(new Intent(StartActivity.this,
						IndexActivity.class));
			}

		});
	}
}